if (typeof inweo.core.tag == "undefined") {
	// needs rethinking, am too lazy to update this list
	inweo.tags = {
		"box"				: "box",
		"vbox"				: "box",
		"hbox"				: "box",
		"button"			: "button",
		"pushButton"		: "button",
		"toggleButton"		: "button",
		"checkboxButton"	: "button",
		"radioButton"		: "button",
		"expander"			: "expander",
		"grid"				: "grid",
		"gridRow"			: "grid",
		"gridItem"			: "grid",
		"gridRowGroup"		: "grid",
		"label"				: "label",
		"menu"				: "menu",
		"menuBar"			: "menu",
		"menuPopUp"			: "menu",
		"menuItem"			: "menu",
		"menuItemSeparator"	: "menu",
		"menuItemGroup"		: "menu",
		"menuItemCheckbox"	: "menu",
		"menuItemRadio"		: "menu",
		"splitterHBox"		: "splitterHBox",
		"splitterVBox"		: "splitterVBox",
		"tabFolder"			: "tabFolder",
		"tabItem"			: "tabFolder",
		"tree"				: "tree",
		"treeGroup"			: "tree",
		"treeItem"			: "tree",
		"window"			: "window"
	}
	inweo.core.tag = new Class({
		initialize: function(parseHTML) {
			this.parseHTML = parseHTML || false;
			if (this.parseHTML == true) {
				this.parseHtml();
			}
		},
		getElements: function(tag) {
			if (navigator.appName == "Microsoft Internet Explorer") {
				return document.body.getElementsByTagName(tag);
			} else {
				return document.body.getElementsByTagName("in:" + tag);
			}
		},
		parseHtml: function() {
			var self = this;
			for (var tag in inweo.tags) {
				var elements = null;
				elements = this.getElements(tag);
				if (elements.length == 0) {
					continue;
				}
				for (var i = 0; i < elements.length; i++) {
					elements[i].id = "tag_" + tag.toLowerCase() + "_" + i;
				}
				var elementsLength = elements.length;
				for (var i = 0; i < elementsLength; i++) {
					element = $("tag_" + tag.toLowerCase() + "_" + i);
					element.id = "";
					inweo.require(inweo.tags[tag]);
					var obj = null;
					var objTag = new inweo.widgets[tag].tag;
					objTag.element = element;
					objTag.widgetName = tag;
					obj = objTag.getWidgetObject();
					objTag.widget = obj.widget;
					obj.widget.setProperty("style", element.getProperty("style"));
					var attributes = element.attributes;
					objTag.insert(element, obj);
					delete element;
					var tmp = [];
					for (var y = 0; y < attributes.length; y++) {
						if (attributes[y].name.substr(0, 7) == "method:") {
							tmp.push(attributes[y]);
						}
					}
					attributes = tmp;
					delete tmp;
					for (var y = 0; y < attributes.length; y++) {
						var method = null;
						try {
							method = obj[attributes[y].name.split(":")[1]];
						} catch(e) {}
						if (typeof method == "function") {
							method.call(obj, attributes[y].value);
						}
					}
				}
			}
		},
		getWidgetObject: function() {
			return new inweo.widgets[this.widgetName];
		},
		insert: function(element, obj) {
			obj.widget.replaces(element);
		}
	});
}